#绘制26个英文之母
import os
from PIL import Image,ImageFont,ImageDraw
from gameSprit import KEY_LIST,BG_PATH

class Draw:
    def __init__(self):
        #设置文件目录
        BG_PATH = './images/hats/'
        #设置文件背景
        self.bj = './images/hat.png'
        #设置字体
        self.font = ImageFont.truetype('C:\\Windows\\FONTS\\SIMKAI.ttf', 36)
        #创建文件目录
        if not os.path.exists(BG_PATH) :
            os.mkdir(BG_PATH)
            self.__drawing()
        elif len(os.listdir(BG_PATH)) != len(KEY_LIST):
            self.__drawing()

    def __drawing(self):
        for letter in KEY_LIST :
            with Image.open(self.bj) as im :
                im_drow = ImageDraw.Draw(im)
                im_drow.multiline_text((8,2),letter, fill=(0, 0, 0), font=self.font)
                im.save(f'{BG_PATH}{letter}.png')

if __name__ == '__main__' :
    Draw()